<template>
  <div>
     <el-card shadow="never" class="d2-mb">
      <el-form class="filter-container" ref="FYGLForm" :model="FYGLForm" label-width="100px">
          <el-row :gutter="20">
             <el-col :span="4">
              <el-form-item label="部门名称">
               <el-select
                v-model="FYGLForm.department"
                placeholder="请选择"
                 clearable
                style="width:100%;"
              >
                  <el-option
                  v-for="item in selectDepartsList"
                  :key="item.department"
                  :label="item.name"
                  :value="item.department"
                >
                </el-option>
                </el-select>
              </el-form-item>
            </el-col>
             <el-col :span="4">
              <el-form-item label="客商">
                   <el-select
                v-model="FYGLForm.customer"
                placeholder="请选择"
                 clearable
                style="width:100%;"
              >
                <el-option
                  v-for="item in customerList"
                  :key="item.customer"
                  :label="item.name"
                  :value="item.customer"
                >
                 <span style="float: left">{{item.name}}</span>
                     <!-- <span style="float: right; color: #8492a6; font-size: 13px">{{ item.customer}}</span> -->
                </el-option>
              </el-select>
              </el-form-item>
            </el-col>
             <el-col :span="3">
              <el-form-item label="购销类型">
                <el-select  clearable v-model="FYGLForm.direction" placeholder="请选择" filterable allow-create>
			            <el-option label="采购" value="0"></el-option>
                  <el-option label="销售" value="1"></el-option>
			        </el-select>
              </el-form-item>
            </el-col>
             <el-col :span="3">
              <el-form-item label="审批状态">
                <el-select  clearable v-model="FYGLForm.status" placeholder="请选择" filterable allow-create>
			            <el-option label="草拟" value="0"></el-option>
                  <el-option label="审核中" value="1"></el-option>
                  <el-option label="已驳回" value="2"></el-option>
                  <el-option label="已退审" value="3"></el-option>
                  <el-option label="已通过" value="4"></el-option>
			        </el-select>
              </el-form-item>
            </el-col>
              <el-col :span="8">
                 <el-form-item label="日期">
                <el-col :span="11">
                  <el-date-picker type="date" placeholder="选择日期" v-model="FYGLForm.startDate" value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
                </el-col>
                <el-col class="line tc" :span="2">~</el-col>
                <el-col :span="11">
                  <el-date-picker type="date" placeholder="选择日期" v-model="FYGLForm.endDate" value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
                </el-col>
              </el-form-item>
            </el-col>
            <el-col :span="2">
              <el-button type="primary" size="small" style='margin-top:3px;' @click="FYGLChange">
                <d2-icon name="search"/> 查询
              </el-button>
            </el-col>
          </el-row>
      </el-form>
    </el-card>
    <div class='mb'>
       <el-button type="default" size="mini" @click="handleFilter_addfygl">
          <d2-icon name="plus"/>
          新增
        </el-button>
         <!-- <el-upload
            class="upload-btn"
            :action="uploadUrl"
            accept=".xls, .xlsx"
            :on-success="handleAvatarSuccess"
            :on-progress="uploadProgress"
            :on-error="handleUploadError"
            :show-file-list="false" style="display:inline-block;margin:0 10px;">
          <el-button type="default" size="small">
            <d2-icon name="download" />
            导入
          </el-button>
          </el-upload> -->
        <el-button type="default" size="mini" @click="handleFilter_editFygl">
          <d2-icon name="edit"/>
          修改
        </el-button>
        <el-button type="default" size="mini" @click="handleFilter_search">
          <d2-icon name="search"/>
          查看
        </el-button>
        <el-button type="default" size="mini" icon="el-icon-delete" @click="handleFilter_delFygl">
          删除
        </el-button>
          <el-button type="default" size="mini" @click="handleFilter_copyFygl">
          <i class="fa fa-clipboard" aria-hidden="true"></i>
          复制
        </el-button>
         <el-button type="default" size="mini" @click="handleFilter_spFygl">
          <i class="fa fa-calendar-check-o" aria-hidden="true"></i>
          提交审批
        </el-button>
         <el-button type="default" size="mini" @click="handle_NospFygl">
          <i class="fa fa-calendar-times-o" aria-hidden="true"></i>
          退审
        </el-button>
         <el-button type="default" size="mini" @click="exportExcel">
          <d2-icon name="upload"/>
          导出
        </el-button>
        <el-button type="default" size="mini" @click="refresh_Fygl">
          <d2-icon name="refresh"/>
          刷新
        </el-button>
         <el-button type="default" size="mini" @click="historicalApproval">
          <i class="fa fa-calendar-plus-o" aria-hidden="true"></i>
          审批历史
        </el-button>
    </div>
    <el-card shadow="never" class="d2-mb titleline">
     <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
         <p class="title_l fl">资金信息</p>
     </template>
     <div>
        <el-table :data="FYGLList" 
        style="width: 100%" 
        :header-cell-style="{ background: '#eef1f6','text-align': 'center' }"
        border
         @selection-change='handleSelectionChange'>
     <el-table-column
      type="selection"
      width="40">
    </el-table-column>
    <el-table-column type="expand" width="40">
      <template slot-scope="props">
        <el-form label-position="left" inline class="demo-table-expand">
          <el-form-item label="申请人">
            <span>{{ props.row.creator_name }}</span>
          </el-form-item>
          <el-form-item label="制单时间">
            <span>{{ props.row.created_time }}</span>
          </el-form-item>
           <el-form-item label="备注">
            <span>{{ props.row.remark }}</span>
          </el-form-item>
        </el-form>
      </template>
    </el-table-column>
    <el-table-column
      label="审批状态"
      prop="status"
       width="105"
      :formatter="formatterSPstatus" sortable
      >
    </el-table-column>
    <el-table-column
      label="部门名称"
      prop="department_name">
    </el-table-column>
    <el-table-column
      label="单据ID" width="70"
      prop="invoices_no">
    </el-table-column>
    <el-table-column
      label="单据日期" width="105"
      prop="date" sortable>
    </el-table-column>
    <el-table-column
      label="购销类型"
      prop="direction" width="80"
      :formatter="formatterDirection">
    </el-table-column>
     <el-table-column
      label="客商"
      prop="customer_name">
    </el-table-column>
    <el-table-column
      label="原币币种ID"
      prop="currency" v-if="a">
    </el-table-column>
    <el-table-column
      label="原币币种"
      prop="currency_name" width="80">
    </el-table-column>
     <el-table-column
      label="原币金额"
      prop="original_price" width="80">
    </el-table-column>
    <el-table-column
      label="汇率" width="60"
      prop="exchange_rate">
    </el-table-column>
    <el-table-column
      label="本币金额"
      prop="currency_price">
    </el-table-column>
    <el-table-column
      label="期初标识"
      prop="begin_flag" width="80"
      :formatter="formatterQC">
    </el-table-column>
    <el-table-column
      label="费用类型"
      prop="cap_type_all">
    </el-table-column>
    <el-table-column
      label="已匹配金额"
      prop="matched_price" width="95">
    </el-table-column>
    <el-table-column
      label="未匹配金额"
      prop="unmatched_price" width="95">
    </el-table-column>
  </el-table>
     </div>
     </el-card> 
      <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="FYGLForm.currentPage"
      :page-size="FYGLForm.pageSize"
      layout="total, prev, pager, next"
      :total="FYGLForm.totalPage"
    >
    </el-pagination>
   <!-- 敞口管理-红冲 -->
    <el-dialog title="红冲" class="tc" :visible.sync="handleFilter_hcVisible">
      <el-row>
        <el-table :data="HCSJ" ref="table1" tooltip-effect="dark" border stripe style="width: 93%" highlight-current-row @current-change="handleCurrentChange">
              <el-table-column label="序号"  type="index" width="60" align="center"></el-table-column>
              <el-table-column  label="日期" align="center" prop="start_date">
              </el-table-column>
              <el-table-column label="单据数量" prop="invoice_vol">
              </el-table-column>
               <el-table-column  label="调整后单据数量" align="center">
                <template slot-scope="scope">
                  <el-input class="adjust_vol" v-model="scope.row.adjust_vol" @input="num_vol"></el-input>
                </template>
              </el-table-column>
              <el-table-column label="差额" prop="shortfall">
              </el-table-column>
        </el-table>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleFilter_hcVisible = false">取消</el-button>
        <el-button type="primary" @click="hcChange">保存</el-button>
      </div>
    </el-dialog>
    <!-- 敞口管理-红冲记录 -->
    <el-dialog title="红冲历史" class="tc" :visible.sync="handleFilter_hcListVisible">
        <el-row>
        <el-table :data="HCList" ref="table" tooltip-effect="dark" border stripe style="width: 93%">
              <el-table-column label="序号"  type="index" width="60" align="center"></el-table-column>
              <el-table-column  label="日期" align="center" prop="date"></el-table-column>
              <el-table-column label="单据数量" prop="invoice_vol"></el-table-column>
               <el-table-column  label="调整后单据数量" align="center" prop="adjust_vol"></el-table-column>
              <el-table-column label="差额" prop="shortfall"></el-table-column>
        </el-table>
        </el-row>
        <el-row>
        </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleFilter_hcListVisible = false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<style>
  .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 20%;
  }
  .el-radio {
  width: 100%;
  text-align: center;
  margin-top: 15px;
}
</style>
<script>
import { concustomer, conspotFee, addspotFee, conCurrency, addworkorder, conworkorderhis } from '../../../../../api/url_lcc';
import { getDepartments } from '../../../../../api/url';
import { approval } from "@/api/url_info.js";
export default {
  name: "gl_cost",
  data () {
    return {
      a:false,
      // 导入
        uploadUrl:`/user/lead/`,
        drFYGLtableData:[],
       selectDepartsList:[],
        customerList:[],
        FYGLForm:{
          page: 1, //当前页
          pageSize: 20,
          totalPage: 1,
          type:"fee",
          "department": "", 
          "customer":  "",  
          "direction": "",  
          "status": "",     
          "startDate": "",  
          "endDate": "",	
          },
        FYGLList: [],
        selectlistRow: [],
        selectCurrencyList:[],
        rowNum:1,
        activeName: 'first',
        searchData: {
        page: 1, //当前页
        pageSize: 20,
        totalPage: 1,
        strategy_name: "",
        strategy_id: "",
        creator: "",
        status: "",
        department_name: "",
        strategy_objective: "",
        strategy_type: "",
        data1:"",
      },
// 1.费用管理
      // 新增
      handleFilter_addQqcjVisible:false,
      // 红冲
      handleFilter_hcVisible:false,
      // 红虫历史
      handleFilter_hcListVisible:false,
     // 修改
      handleFilter_editQqcjVisible:false,
      // 复制
      handleFilter_copyQqcjVisible:false,
      // 调整
      handleFilter_adjustQqcjVisible:false,
      
      edit_Risk_OrderFormVisible: false,
    
    }
  },
  created() {
           this.tabledatas = [
               { title: '标题1', text: 's111sssa' },
               { title: '标题2', text: 'ss222ssa' },
           ]
           this.tabledatas.map(i => {
               i.show = false
               return i
           })
  },
  methods: {
    // ////////////////////////////////////////////////////////////敞口管理
    // 资金导入
     handleAvatarSuccess (res, file) {
        // this.uploadloading.close();
        console.log(444444,res.result);
        if (res && res.errcode === "1") {
           this.$message({
           message: '导入成功',
           type: 'success',
          })
          this.drCKdialogVisible = true;
          this.drCKtableData = [];
          var data3 = res.result.Sheet1;
          for (var i = 0; i < data3.length; i++) {
            this.drCKtableData[i] = {
              department: data3[i].部门名称,
              customer: data3[i].客户名称,
              currency: data3[i].币种ID,
              direction: data3[i].方向,
              virtual: data3[i].虚拟购销,
              begin_flag: data3[i].期初标识,
              exp_type: data3[i].敞口类型,
              pricing_method: data3[i].定价方式,
              deal_no: data3[i].合同号,
              commodity: data3[i].品名ID,
              depot: data3[i].仓库,
              invoice_vol: data3[i].单据数量,
              exp_vol: data3[i].敞口数量,
              start_date: data3[i].定价开始日期,
              base_price: data3[i].定价基准,
              base_valuation: data3[i].估值基准,
              exchange_rate: data3[i].汇率,
              unit_price: data3[i].单价,
              bwd: data3[i].升贴水,
              price: data3[i].价格,
              currency_price: data3[i].本币价格,
              piece_num: data3[i].件数,
              piece_vol: data3[i].每件数量,
              end_date: data3[i].定价结束日期,
              remark: data3[i].备注,
            }
          }
        } else {
          this.$message.error(res.msg);
        }
      },
      drCK(){
        var drCKtableData = [];
        var drCKtableData = this.drCKtableData;
        drCKtableData.forEach(function(item, index) {
           var data1 = item.exp_type
           var data2 = item.pricing_method
           var data3 = item.direction
           var data4 = item.virtual
           var data5 = item.begin_flag
          if (data2 == "一口价") {
             item.pricing_method = '0';
         } else if (data2 == "点价") {
             item.pricing_method = '1';
         } else if (data2 == "均价") {
             item.pricing_method = '2';
         }
          if (data1 == "逐笔") {
             item.exp_type = '0';
         } else if (data1 == "净敞口") {
             item.exp_type = '1';
         }
           if (data3 == "采购") {
             item.direction = '0';
         } else if (data3 == "销售") {
             item.direction = '1';
         }
           if (data4 == "是") {
             item.virtual = '1';
         } else if (data4 == "否") {
             item.virtual = '0';
         }
           if (data5 == "是") {
             item.begin_flag = '1';
         } else if (data5 == "否") {
             item.begin_flag = '0';
         }
       })
        let params = {
            "operation":"LEAD",
            data:this.drCKtableData
        };
        addExposure(params).then(res => {
                this.$message.success(res.result);
                 this.drCKdialogVisible = false;
             }).catch(err =>{
          this.$message.error(err.msg);
        });
      },
  //  部门信息
     //树形结构转换为扁平数组
    treeToList(tree) {
      var queen = [];
      var out = [];
      queen = queen.concat(tree);
      while (queen.length) {
        var first = queen.shift();
        if (first.sub_depart) {
          queen = queen.concat(first.sub_depart);
          delete first["sub_depart"];
        }
        out.push(first);
      }
      return out;
    },
     // 查询部门
    handle_getDepartments() {
      getDepartments()
        .then(res => {
          this.selectDepartsList = [];
          var data1 = res.result;
          var arr = this.treeToList(data1);
          for (var i = 0; i < arr.length; i++) {
            this.selectDepartsList[i] = {
              name: arr[i]["name"],
              department: arr[i]["id"]
            };
          }
        })
        .catch(err => {
          this.$message.error(err.msg);
        });
    },
    //  客商信息
     handle_customerChange(){
       concustomer(this.cusForm).then(res => {
          this.customerList = []
            var data = res.result
            for (var i = 0; i < data.length; i++) {
              this.customerList[i] = {
                  'customer': data[i].id,
                  'name': data[i].name
              }
            }
            // console.log(1,data,2,this.customerList)
         }).catch(err =>{
          this.$message.error(err.msg);
        });
    },
  //  审批状态
  formatterSPstatus(row, column) {
         if (row.status == "0") {
             return '草拟';
         } else if (row.status == "1") {
             return '审核中';
         } else if (row.status == "4") {
             return '已通过';
         } else if (row.status == "2") {
             return '已驳回';
         } else if (row.status == "3") {
             return '已退审';
         } 
     },
    //  费用类型
    formatterCost(row, column) {
      if (row.cap_type_all == "0") {
             return '货款';
         } else if (row.cap_type_all == "1") {
             return '资金划拨';
         } else if (row.cap_type_all == "2") {
             return '利息';
         } else if (row.cap_type_all == "3") {
             return '运输费';
         } else if (row.cap_type_all == "4") {
             return '装卸费';
         } else if (row.cap_type_all == "5") {
             return '仓储费';
         } else if (row.cap_type_all == "6") {
             return '保险费';
         } else if (row.cap_type_all == "7") {
             return '质押费';
         } else if (row.cap_type_all == "8") {
             return '清关费';
         } 
     },
     // 是否红冲
   formatterRD(row,column){
       return row.status = "0"?'否':'是'
   },
    // 敞口类型逐笔，净敞口
    formatterET(row, column) {
         if (row.exp_type == "0") {
             return '逐笔';
         } else if (row.exp_type == "1") {
             return '净敞口';
         } 
     },
    //  购销类型
    formatterDirection(row, column) {
         if (row.direction == "0") {
             return '采购';
         } else if (row.direction == "1") {
             return '销售';
         } 
     },
       // 期初标志
    formatterQC(row,column){
        // return row.begin_flag = "0"?'否':'是'
         if (row.begin_flag == "0") {
             return '否';
         } else if (row.begin_flag == "1") {
             return '是';
         } else if (row.begin_flag == "2") {
             return '是';
         } 
    },
     // 查询币种
      handle_currencyChange(){
         let params = {
              "name": "",
          };
          conCurrency(params).then(res => {
                 this.selectCurrencyList = []
                  var data1 = res.result
                  // console.log(902,)
                for (var i = 0; i < data1.length; i++) {
                        this.selectCurrencyList[i] = {
                            currency: data1[i]['id'],
                            name: data1[i]['name']
                        };
                    }
             }).catch(err =>{
          this.$message.error(err.msg);
        });
      },
    // 行内编辑
    handleCellDataChange ({ rowIndex, key, value, row }) {
      console.log(rowIndex)
      console.log(key)
      console.log(value)
      console.log(row) 
    },
    handleUpload (file) {
      this.$import.xlsx(file)
        .then(({ header, results }) => {
          this.table.columns = header.map(e => {
            return {
              label: e,
              prop: e
            }
          })
          this.table.data = results
        })
      return false
    },
    // 多选
    handleSelectionChange(val) {
       this.multipleSelection = val;
       console.log('多选',this.multipleSelection)
     },
   // 多选提示
    openMessage() {
      this.$message({
          dangerouslyUseHTMLString: true,
          type: 'error',
          message: '<strong>请勾选你要选择的行，再进行操作！</strong>'
      });
    },
     // 获取表格选中时的数据
      selectRow (val) {
        this.selectlistRow = val
      },
    // ////////////////////////////////////////////////////////////费用管理
     // 每页数
    handleSizeChange(val) {
      this.FYGLForm.pageSize = val;
      this.FYGLForm.page = 1;
     this.FYGLChange1();
    },
    // 当前页
    handleCurrentChange(val) {
      console.log(val);
      this.FYGLForm.page = val;
      this.FYGLChange1();
    },
    // 查询
     FYGLChange(){
      this.FYGLForm.page = 1;
      this.FYGLChange1();
      this.handle_currencyChange()
    },
    FYGLChange1(){
        conspotFee(this.FYGLForm).then(res => {
                this.FYGLList = []
                var data = res.result.results
                 this.FYGLForm.totalPage = res.result.count;
                for (var i = 0; i < data.length; i++) {
                  this.FYGLList = data
                  console.log(162,data)
              }
             }).catch(err =>{
          this.$message.error(err.msg);
        });
    },
    // 新增
    handleFilter_addfygl(){
      this.$router.push({path: '/add_cost'});
    },
    // 修改
    handleFilter_editFygl(){
      var data = this.multipleSelection
       if (this.multipleSelection == "undefined") {
           this.openMessage();
       } else if(this.multipleSelection.length != 1){
          this.$message.error("退审只能选中一条数据进行！");
       } else if(this.multipleSelection[0].status === 0 || this.multipleSelection[0].status === 2 || this.multipleSelection[0].status === 3){
          this.$router.push({name: 'edit_cost', params: {editList: data, type:'edit'}})
       }else{
         this.$message.error("修改只能选择草拟或已驳回或已退审状态费用信息！");
       }
    },
    // 复制
     handleFilter_copyFygl(){
       var data = this.multipleSelection
       if (this.multipleSelection == undefined) {
           this.openMessage();
       } else if(this.multipleSelection.length != 1){
          this.$message.error("修改只能选中一条数据进行！");
       } else {
          this.$router.push({name: 'edit_cost', params: {editList: data, type:'copy'}})
       }
    },
    // 查看
    handleFilter_search(){
      // console.log(129,this.multipleSelection)
      var data = this.multipleSelection
      if (this.multipleSelection == undefined) {
           this.openMessage();
       }else{
          this.$router.push({name: 'edit_cost', params: {editList: data, type:'look'}})
       }
    },
    // 删除
    handleFilter_delFygl(){
      // console.log(90,this.multipleSelection)
       var data = this.multipleSelection
       var Newdata  = [];
       data.forEach(function(item, index) {
           var data1 = item.status
           Newdata.push(data1)
        }) 
       if(this.multipleSelection == undefined) {
           this.openMessage();
       }else if(Newdata.indexOf(1) == '0' || Newdata.indexOf(4) == '0'){
          this.$message.error("删除只能选择草拟或已驳回或已退审状态费用信息！");
       }else{
         this.delList()
       }
    },
    del_message(){
       var data = this.multipleSelection
       var Newdata  = [];
       data.forEach(function(item, index) {
           var data1 = item.invoices_no
           Newdata.push(data1)
          //  console.log(90,data1,91,Newdata)
        })
         let params = {
            operation: 'DEL',
            spot_cap: Newdata
        };
        addspotFee(params).then(res => {
                this.$message.success(res.result);
                 this.FYGLChange();
            }).catch(err =>{
          this.$message.error(err.msg);
        });
    },
     // 删除提示信息
    delList() {
       this.$confirm('是否删除数据?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.del_message()
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      },
     // 提交审批workOrderID
    handleFilter_spFygl(){
        var data = this.multipleSelection[0]
        let objToStr = JSON.stringify(this.multipleSelection[0]);
       if (this.multipleSelection == undefined) {
           this.openMessage();
       } else if(this.multipleSelection.length != 1){
          this.$message.error("审批只能选中一条数据进行！");
       } else{
          let params = {
          operation: "ADD",
          business_id: this.multipleSelection[0].invoices_no,
          desc: objToStr,
          task: "SCOST"
        };
        approval(params).then(res => {
            this.FYGLChange();
            this.$message({
              message: res.result,
              type: "success"
            });
          })
          .catch(err => {
            this.$message.error(err.msg);
          });
       }
     
    },
     //审批历史
    historicalApproval(row) {
      // console.log('8',this.multipleSelection)
       if (this.multipleSelection == undefined) {
           this.openMessage();
       } else if(this.multipleSelection.length != 1){
          this.$message.error("审批只能选中一条数据进行！");
       }  else if(this.multipleSelection[0].status === 0){
          this.$message.error("草拟状态数据无审批历史！");
       } else{
           this.$router.push(
          "/examine_historyss?id=" +
            this.multipleSelection[0].workOrderID
        );
        };
     
    },
    // 退审
    handle_NospFygl(){
      // console.log(12,this.multipleSelection)
        var data = this.multipleSelection
       if (this.multipleSelection == undefined) {
           this.openMessage();
       } else if(this.multipleSelection.length != 1){
          this.$message.error("退审只能选中一条数据进行！");
       } else if(this.multipleSelection[0].status != '1'){
          this.$message.error("退审只能选择审批中状态的费用信息！");
       } else{
         let params = {
            operation: "MOD",
            id: this.multipleSelection[0].workOrderID,
            status: 3,
            opinion: ""
          };
          approval(params)
            .then(res => {
              this.FYGLChange();
              this.$message({
                message: res.result,
                type: "success"
              });
            })
            .catch(err => {
              this.$message.error(err.msg);
            });
        } 
    },
    // 刷新
    refresh_Fygl(){
      this.FYGLForm.department = "", 
      this.FYGLForm.customer = "",  
      this.FYGLForm.direction = "",  
      this.FYGLForm.status = "",     
      this.FYGLForm.startDate = "",  
      this.FYGLForm.endDate = "",
       this.FYGLChange()
    },
  },
  mounted() {
    this.FYGLChange();
    this.handle_getDepartments();
    this.handle_customerChange();
   }
  }
</script>
